Class Edge

java.lang.Object
edu.claflin.finder.logic.Edge

public class Edge extends Object
Represents an Edge in memory. A simple implementation requiring only two nodes and a single piece of edge data.
Version:
3.1 February 2, 2016
Author:
Charles Allen Schultz II
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private double
    The data attached to the edge.
    private Node
    The node representing the source.
    private Node
    The node representing the target.
    private boolean
    Indicates if this edge should be treated as being undirected.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Edge(Node source, Node target, double data, boolean undirected)
    Initializes the Edge object.
  • Method Summary

    Modifier and Type
    Method
    Description
    duplicate(Node source, Node destination)
    Attempts to duplicate an Edge based on the supplied parameters.
    boolean
     
    double
    Access method for the Edge's data (such as weight).
     
     
    Access method for the Edge's source.
    Access method for the Edge's target.
    int
     
    boolean
    Determines whether the given Node is involved in the Edge.
    boolean
    Access method for the Edge's undirectedness parameter.
    void
    Access method for the Edge's data (such as weight).
    void
    setUndirected(boolean undirected)
    Access method for the Edge's undirectedness parameter.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • source

      private Node source
      The node representing the source.
    • target

      private Node target
      The node representing the target.
    • data

      private double data
      The data attached to the edge.
    • undirected

      private boolean undirected
      Indicates if this edge should be treated as being undirected.
  • Constructor Details

    • Edge

      public Edge(Node source, Node target, double data, boolean undirected)
      Initializes the Edge object.
      Parameters:
      source - the Node representing the interaction source.
      target - the Node representing the interaction target.
      data - the Object representing the Edge data.
      undirected - the boolean indicating if this edge is undirected.
  • Method Details

    • getSource

      public Node getSource()
      Access method for the Edge's source.
      Returns:
      the Node representing the source.
    • getTarget

      public Node getTarget()
      Access method for the Edge's target.
      Returns:
      the Node representing the target.
    • getEndpoints

      public List<Node> getEndpoints()
    • getOther

      public Node getOther(Node n)
    • getData

      public double getData()
      Access method for the Edge's data (such as weight).
      Returns:
      the Object representing the data.
    • setData

      public void setData(Double data)
      Access method for the Edge's data (such as weight).
      Parameters:
      data - the new data for the edge.
    • isUndirected

      public boolean isUndirected()
      Access method for the Edge's undirectedness parameter.
      Returns:
      the boolean indicating if this edge is undirected.
    • setUndirected

      public void setUndirected(boolean undirected)
      Access method for the Edge's undirectedness parameter.
      Parameters:
      undirected - a boolean indicating if this edge should be undirected.
    • includes

      public boolean includes(Node n)
      Determines whether the given Node is involved in the Edge.
      Parameters:
      n - the Node to verify is in the Edge
      Returns:
      whether the given Node is involved in the Edge
    • duplicate

      public Edge duplicate(Node source, Node destination)
      Attempts to duplicate an Edge based on the supplied parameters. The data attached to the edge REMAINS THE SAME OBJECT as the original graph. As such, non-immutable objects will reflect changes across both edges. The supplied Node objects must be equivalent to the old ones.
      Parameters:
      source - the new Source node reference to utilize.
      destination - the new Destination node reference to utilize.
      Returns:
      a duplicate Edge decoupled from the original Graph.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object